package com.jinzhi.jzweb.controller;


import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.jinzhi.common.annotation.Log;
import com.jinzhi.common.base.BaseController;
import com.jinzhi.common.service.DictService;
import com.jinzhi.common.type.EnumErrorCode;
import com.jinzhi.common.utils.EhCacheUtil;
import com.jinzhi.common.utils.Result;
import com.jinzhi.jzapi.examination.pojo.ExaminationsVo;
import com.jinzhi.jzapi.msg.WxPushServiceQcl;
import com.jinzhi.jzweb.domain.*;
import com.jinzhi.jzweb.pojo.*;
import com.jinzhi.jzweb.pojo.ModuleConfig.JzJinzhuanDispositionModule;
import com.jinzhi.jzweb.service.*;
import com.jinzhi.jzweb.service.moduleConfig.IJzJinzhuanDispositionModuleService;
import com.jinzhi.jzweb.utils.EasyPoiUtil;
import com.jinzhi.sys.domain.UserDO;
import com.jinzhi.sys.service.UserRoleService;
import com.jinzhi.sys.service.UserService;
import com.jinzhi.wxmp.service.MpConfigService;
import lombok.val;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.StringReader;
import java.net.URLEncoder;
import java.util.*;

/**
 * 
 * <pre>
 *  实操模块打分
 *  实操裁判打分
 * </pre>
 * <small> 2023-05-05 08:52:02 | lance</small>
 */
@Controller
@RequestMapping("/jzweb/stuSignUpScoring")
public class StuSignUpComScoringController extends BaseController {
	@Autowired
	private StuSignUpComService stuSignUpComService;
	@Autowired
	private StuSignUpComService stuSignUpService;
	@Autowired
	private UserService userService;
	@Autowired
	private DictService dictService;
	@Autowired
	private ExaminationBatchComService examinationBatchService;

	@Autowired
	private ExaminationBatchService examinationBatchService1;
	@Autowired
	private ExaminationResultsComService examinationResultsService;
	@Autowired
	private ExaminationBatchComService  examinationBatchComDO;
	@Autowired
	private ExaminationBatchComSService examinationBatchsService;
	@Autowired
	private ExaminationResultsImgMp4ComService imgMp4ComService;

	@Autowired
	private IJzJinzhuanDispositionModuleService jinzhuanDispositionModuleService;

	@ResponseBody
	@GetMapping("/list")
	@RequiresPermissions("jzweb:stuSignUpScoring:stuSignUpScoring")
	public Object list(StuSignUpComDO stuSignUpComDTO){
		// 查询列表数据
//		Page<StuSignUpComDO> page = stuSignUpComService.selectPage(getPage(StuSignUpComDO.class),
//					stuSignUpComService.convertToEntityWrapper().eq("types",stuSignUpComDTO.getTypes()).orderBy("id", false));
//
		List <StuSignUpComDO> stuSignUpComDOS=	stuSignUpComService.findByKv("types",stuSignUpComDTO.getTypes());

//		List<StuSignUpComDO> list = new ArrayList();
//		for (StuSignUpComDO li:stuSignUpComDOS ) {
//
//				list.add();
//		}
		return Result.ok(stuSignUpComDOS);
	}


	/**
	 * 超级管理员修改理论分数
	 * 理论修改分数跳转
	 * @param id
	 * @param model
	 * @param type
	 * @return
	 */
	@GetMapping("/exitScoreBc")
	@RequiresPermissions("jzweb:examinationResultsABC:edit")
	String exitScore(){
		return "jzweb/examinationAnswerSheetCom/exitScoreBC";
	}

	/**
	 * 超级管理员修改理论分数
	 * 理论修改分数跳转
	 * @return
	 */
	@GetMapping("/rubrinfoBC")
	@RequiresPermissions("jzweb:examinationResultsABC:edit")
	String rubrinfoBC(){
		return "jzweb/examinationAnswerSheetCom/rubrinfo";
	}

	/**
	 * 超级管理员修改分数
	 * 实操
	 * @return
	 */
	@RequestMapping("/updateScoingABCUpdate")
	@ResponseBody
	@RequiresPermissions("jzweb:examinationResultsABC:edit")
	Result<String>  updateScoingABCUpdate(OneLevelComAdminVO oneLevelComVO){
		if(oneLevelComVO.getId()==null){
			return 	Result.fail("参赛序号不存在！");
		}
		List<ExaminationResultsComDO> examinationAnswerSheetDOs = examinationResultsService
				.findByKv("id", oneLevelComVO.getId());
		if(examinationAnswerSheetDOs.size()==0){
			return 	Result.fail("未进行阅卷不能进行评分！");
		}
		if(oneLevelComVO.getScoingc3()!=null){

			examinationAnswerSheetDOs.get(0).setScoingc3(oneLevelComVO.getScoingc3());
		}
		if(oneLevelComVO.getScoingc2()!=null){
			examinationAnswerSheetDOs.get(0).setScoingc2(oneLevelComVO.getScoingc2());
		}
		if(oneLevelComVO.getScoingc1()!=null){
			examinationAnswerSheetDOs.get(0).setScoingc1(oneLevelComVO.getScoingc1());
		}
		if(oneLevelComVO.getScoingc4()!=null){
			examinationAnswerSheetDOs.get(0).setScoingc4(oneLevelComVO.getScoingc4());
		}
		if(oneLevelComVO.getScoingc5()!=null){
			examinationAnswerSheetDOs.get(0).setScoingc5(oneLevelComVO.getScoingc5());
		}



		if(oneLevelComVO.getScoingb1()!=null){
			examinationAnswerSheetDOs.get(0).setScoingb1(oneLevelComVO.getScoingb1());
		}
		if(oneLevelComVO.getScoingb2()!=null){
			examinationAnswerSheetDOs.get(0).setScoingb2(oneLevelComVO.getScoingb2());
		}
		if(oneLevelComVO.getScoingb3()!=null){
			examinationAnswerSheetDOs.get(0).setScoingb3(oneLevelComVO.getScoingb3());
		}
		if(oneLevelComVO.getScoingb4()!=null){
			examinationAnswerSheetDOs.get(0).setScoingb4(oneLevelComVO.getScoingb4());
		}
		if(oneLevelComVO.getScoingb5()!=null){
			examinationAnswerSheetDOs.get(0).setScoingb5(oneLevelComVO.getScoingb5());
		}




		if(oneLevelComVO.getScoingc3s()!=null){
			examinationAnswerSheetDOs.get(0).setScoingc3s(oneLevelComVO.getScoingc3s());
		}
		if(oneLevelComVO.getScoingc2s()!=null){
			examinationAnswerSheetDOs.get(0).setScoingc2s(oneLevelComVO.getScoingc2s());
		}
		if(oneLevelComVO.getScoingc1s()!=null){
			examinationAnswerSheetDOs.get(0).setScoingc1s(oneLevelComVO.getScoingc1s());
		}
		if(oneLevelComVO.getScoingc4s()!=null){
			examinationAnswerSheetDOs.get(0).setScoingc4s(oneLevelComVO.getScoingc4s());
		}
		if(oneLevelComVO.getScoingc5s()!=null){
			examinationAnswerSheetDOs.get(0).setScoingc5s(oneLevelComVO.getScoingc5s());
		}



		if(oneLevelComVO.getScoingb1s()!=null){
			examinationAnswerSheetDOs.get(0).setScoingb1s(oneLevelComVO.getScoingb1s());
		}
		if(oneLevelComVO.getScoingb2s()!=null){
			examinationAnswerSheetDOs.get(0).setScoingb2s(oneLevelComVO.getScoingb2s());
		}
		if(oneLevelComVO.getScoingb3s()!=null){
			examinationAnswerSheetDOs.get(0).setScoingb3s(oneLevelComVO.getScoingb3s());
		}
		if(oneLevelComVO.getScoingb4s()!=null){
			examinationAnswerSheetDOs.get(0).setScoingb4s(oneLevelComVO.getScoingb4s());
		}
		if(oneLevelComVO.getScoingb5s()!=null){
			examinationAnswerSheetDOs.get(0).setScoingb5s(oneLevelComVO.getScoingb5s());
		}


		boolean b = examinationResultsService.updateById(examinationAnswerSheetDOs.get(0));
		return b==true?Result.ok():Result.fail();
	}



	/**
	 * 裁判评分查看列表
	 *
	 * @return
	 */
	@GetMapping("/resultListYesOrNo")
	@ResponseBody
	Object  resultListYesOrNo(Long id){
		ExaminationBatchComSDO  examinationBatchComSDO= examinationBatchsService.selectById(id);

		ExaminationBatchComDO selectById=examinationBatchComDO.selectById(examinationBatchComSDO.getPId());

		if(selectById.getCbatchId()==null){
			return Result.fail("未进行理论考试关联不能进行评分！");
		}
		if(selectById.getState()!=4&&selectById.getState()!=5&&selectById.getState()!=6&&selectById.getState()!=1){
			return Result.fail("该考试批次状态无法进行评分！");
		}
		Wrapper<ExaminationResultsComDO> wrapper=new EntityWrapper<>();
		wrapper.eq("ebatch_id",selectById.getCbatchId());
		List list=examinationResultsService.selectList(wrapper);
	if(list.size()==0){
		return Result.fail("未进行理论考试阅卷不能进行评分！");
	}
		return Result.ok();
	}


	@PostMapping("/ersPage")
	@ResponseBody
	public Result<Object> stuCom(String court2,String current,String number){
		//实操打分人员查询
//		String current = "0";
//		String number = "10";
		Page<ExaminationResultsPoVo> page =	examinationResultsService.resultList(Integer.valueOf(current),Integer.valueOf(number),court2);//cbatchId
		return Result.ok(page);
	}



	@GetMapping()
	@RequiresPermissions("jzweb:stuSignUpScoring:stuSignUpScoring")
	Object StuSignUpCom(Long ebatchId, Long modileId, String court2, Model model){
		System.out.println("court2====}"+court2);
//		List<ExaminationResultsPoVo>  list=	examinationResultsService.resultList(ebatchId,court2);//cbatchId
		//查询出对应的模版信息
		List<JzJinzhuanDispositionModule> modules = jinzhuanDispositionModuleService.getModuleList(new JzJinzhuanDispositionModule().setId(modileId));
//		model.addAttribute("stuSignUpCom",list);
		model.addAttribute("modile",modules);
		return "jzweb/stuSignUpCom/shotrating";
	}


	//查询出所有批次（前台选择）
	@GetMapping("/batch")
	@ResponseBody
	Object batch(){
		//查询出所有批次
		List<ExaminationBatchDO> list = examinationBatchService1.findByKv();
		return Result.ok(list);
	}

	/**
	 * 实操裁判B 打分
	 * @return
	 */
	@GetMapping("/scoingb1")
	@ResponseBody
	@RequiresPermissions("jzweb:stuSignUpScoring:scoingb1")
	Result<String>  scoingb(ResultsImgMp4Vo resultsImgMp4Vo){

		List<ExaminationResultsComDO> examinationAnswerSheetDOs = examinationResultsService
				.findByKv("stu_sign_id", resultsImgMp4Vo.getId());
		if(examinationAnswerSheetDOs.size()==0){
			return 	Result.fail("未进行阅卷不能进行评分！");
		}
		if(resultsImgMp4Vo.getScoingb1()!=null){
			examinationAnswerSheetDOs.get(0).setScoingb1(resultsImgMp4Vo.getScoingb1());
		}
		if(resultsImgMp4Vo.getScoingb1s()!=null){
			examinationAnswerSheetDOs.get(0).setScoingb1s(resultsImgMp4Vo.getScoingb1s());
		}
		boolean b = examinationResultsService.updateById(examinationAnswerSheetDOs.get(0));
		boolean b1=imgMp4ComService.saves(resultsImgMp4Vo);

		return b==true?Result.ok():Result.fail();
	}



/*	*//**
	 * 裁判评分查看列表
	 *
	 * @return
	 *//*
	@GetMapping("/resultList")
	@ResponseBody
	@RequiresPermissions("jzweb:stuSignUpScoring:resultList")
	Object  resultList(Long id,Long cbatchId){
		List<ExaminationResultsPoVo> list=examinationResultsService.resultList(id,cbatchId);
		return Result.ok(list);
	}*/

	/**
	 * 实操裁判B 打分
	 * @return
	 */
	@GetMapping("/scoingb2")
	@ResponseBody
	@RequiresPermissions("jzweb:stuSignUpScoring:scoingb2")
	Result<String>  scoingb2(ResultsImgMp4Vo resultsImgMp4Vo){

		List<ExaminationResultsComDO> examinationAnswerSheetDOs = examinationResultsService
				.findByKv("stu_sign_id", resultsImgMp4Vo.getId());
		if(examinationAnswerSheetDOs.size()==0){
			return 	Result.fail("未进行阅卷不能进行评分！");
		}
		if(resultsImgMp4Vo.getScoingb2()!=null){
			examinationAnswerSheetDOs.get(0).setScoingb2(resultsImgMp4Vo.getScoingb2());
		}
		if(resultsImgMp4Vo.getScoingb2s()!=null){
			examinationAnswerSheetDOs.get(0).setScoingb2s(resultsImgMp4Vo.getScoingb2s());
		}
		boolean b = examinationResultsService.updateById(examinationAnswerSheetDOs.get(0));
		ExaminationResultsComResourcesDO resultsComResourcesDO=imgMp4ComService.findOneByKv("results_id",resultsImgMp4Vo.getIds());
		if(resultsComResourcesDO==null){
			ExaminationResultsComResourcesDO comResourcesDO=new ExaminationResultsComResourcesDO();
			comResourcesDO.setResultsId(resultsImgMp4Vo.getIds());
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingb1img())){
				comResourcesDO.setScoingb2img(resultsImgMp4Vo.getScoingb1img());
			}
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingb1smp4())){
				comResourcesDO.setScoingb2smp4(resultsImgMp4Vo.getScoingb1smp4());
			}
				  imgMp4ComService.insert(comResourcesDO);
		}else {
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingb1img())){
				resultsComResourcesDO.setScoingb2img(resultsImgMp4Vo.getScoingb1img());
			}
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingb1smp4())){
				resultsComResourcesDO.setScoingb2smp4(resultsImgMp4Vo.getScoingb1smp4());
			}
			imgMp4ComService.updateById(resultsComResourcesDO);
		}

		return b==true?Result.ok():Result.fail();
	}

	/**
	 * 实操裁判B 打分
	 * @return
	 */
	@GetMapping("/scoingb3")
	@ResponseBody
	@RequiresPermissions("jzweb:stuSignUpScoring:scoingb3")
	Result<String>  scoingb3(ResultsImgMp4Vo resultsImgMp4Vo){

		List<ExaminationResultsComDO> examinationAnswerSheetDOs = examinationResultsService
				.findByKv("stu_sign_id", resultsImgMp4Vo.getId());
		if(examinationAnswerSheetDOs.size()==0){
			return 	Result.fail("未进行阅卷不能进行评分！");
		}
		if(resultsImgMp4Vo.getScoingb3()!=null){
			examinationAnswerSheetDOs.get(0).setScoingb3(resultsImgMp4Vo.getScoingb3());
		}
		if(resultsImgMp4Vo.getScoingb3s()!=null){
			examinationAnswerSheetDOs.get(0).setScoingb3s(resultsImgMp4Vo.getScoingb3s());
		}
		boolean b = examinationResultsService.updateById(examinationAnswerSheetDOs.get(0));
		ExaminationResultsComResourcesDO resultsComResourcesDO=imgMp4ComService.findOneByKv("results_id",resultsImgMp4Vo.getIds());

		if(resultsComResourcesDO==null){
			ExaminationResultsComResourcesDO comResourcesDO=new ExaminationResultsComResourcesDO();
			comResourcesDO.setResultsId(resultsImgMp4Vo.getIds());
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingb1img())){


				comResourcesDO.setScoingb3img(resultsImgMp4Vo.getScoingb1img());


			}
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingb1smp4())) {
				comResourcesDO.setScoingb3smp4(resultsImgMp4Vo.getScoingb1smp4());
			}
			imgMp4ComService.insert(comResourcesDO);
			}else {
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingb1img())){
				resultsComResourcesDO.setScoingb3img(resultsImgMp4Vo.getScoingb1img());
			}
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingb1smp4())){
				resultsComResourcesDO.setScoingb3smp4(resultsImgMp4Vo.getScoingb1smp4());
			}
			imgMp4ComService.updateById(resultsComResourcesDO);
		}


		return b==true?Result.ok():Result.fail();
	}

	/**
	 * 实操裁判B4 打分
	 * @return
	 */
	@GetMapping("/scoingb4")
	@ResponseBody
	@RequiresPermissions("jzweb:stuSignUpScoring:scoingb4")
	Result<String>  scoingb4(ResultsImgMp4Vo resultsImgMp4Vo){

		List<ExaminationResultsComDO> examinationAnswerSheetDOs = examinationResultsService
				.findByKv("stu_sign_id", resultsImgMp4Vo.getId());
		if(examinationAnswerSheetDOs.size()==0){
			return 	Result.fail("未进行阅卷不能进行评分！");
		}
		if(resultsImgMp4Vo.getScoingb4()!=null){
			examinationAnswerSheetDOs.get(0).setScoingb4(resultsImgMp4Vo.getScoingb4());
		}
		if(resultsImgMp4Vo.getScoingb4s()!=null){
			examinationAnswerSheetDOs.get(0).setScoingb4s(resultsImgMp4Vo.getScoingb4s());
		}
		boolean b = examinationResultsService.updateById(examinationAnswerSheetDOs.get(0));
		ExaminationResultsComResourcesDO resultsComResourcesDO=imgMp4ComService.findOneByKv("results_id",resultsImgMp4Vo.getIds());

		if(resultsComResourcesDO==null){
			ExaminationResultsComResourcesDO comResourcesDO=new ExaminationResultsComResourcesDO();
			comResourcesDO.setResultsId(resultsImgMp4Vo.getIds());
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingb1img())){
				comResourcesDO.setScoingb4img(resultsImgMp4Vo.getScoingb1img());
			}

			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingb1smp4())) {
				comResourcesDO.setScoingb4smp4(resultsImgMp4Vo.getScoingb1smp4());
			}
			imgMp4ComService.insert(comResourcesDO);
			}else {
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingb1img())){
				resultsComResourcesDO.setScoingb4img(resultsImgMp4Vo.getScoingb1img());
			}
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingb1smp4())){
				resultsComResourcesDO.setScoingb4smp4(resultsImgMp4Vo.getScoingb1smp4());
			}
			imgMp4ComService.updateById(resultsComResourcesDO);
		}

		return b==true?Result.ok():Result.fail();
	}

	/**
	 * 实操裁判B5 打分
	 * @return
	 */
	@GetMapping("/scoingb5")
	@ResponseBody
	@RequiresPermissions("jzweb:stuSignUpScoring:scoingb5")
	Result<String>  scoingb5(ResultsImgMp4Vo resultsImgMp4Vo){

		List<ExaminationResultsComDO> examinationAnswerSheetDOs = examinationResultsService
				.findByKv("stu_sign_id", resultsImgMp4Vo.getId());
		if(examinationAnswerSheetDOs.size()==0){
			return 	Result.fail("未进行阅卷不能进行评分！");
		}
		if(resultsImgMp4Vo.getScoingb5()!=null){
			examinationAnswerSheetDOs.get(0).setScoingb5(resultsImgMp4Vo.getScoingb5());
		}
		if(resultsImgMp4Vo.getScoingb5s()!=null){
			examinationAnswerSheetDOs.get(0).setScoingb5s(resultsImgMp4Vo.getScoingb5s());
		}
		boolean b = examinationResultsService.updateById(examinationAnswerSheetDOs.get(0));
		ExaminationResultsComResourcesDO resultsComResourcesDO=imgMp4ComService.findOneByKv("results_id",resultsImgMp4Vo.getIds());

		if(resultsComResourcesDO==null){
			ExaminationResultsComResourcesDO comResourcesDO=new ExaminationResultsComResourcesDO();
			comResourcesDO.setResultsId(resultsImgMp4Vo.getIds());
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingb1img())){
				comResourcesDO.setScoingb5img(resultsImgMp4Vo.getScoingb1img());


			}
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingb1smp4())) {
				comResourcesDO.setScoingb5smp4(resultsImgMp4Vo.getScoingb1smp4());
			}
			imgMp4ComService.insert(comResourcesDO);
			}else {
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingb1img())){
				resultsComResourcesDO.setScoingb5img(resultsImgMp4Vo.getScoingb1img());
			}
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingb1smp4())){
				resultsComResourcesDO.setScoingb5smp4(resultsImgMp4Vo.getScoingb1smp4());
			}
			imgMp4ComService.updateById(resultsComResourcesDO);
		}

		return b==true?Result.ok():Result.fail();
	}

	/**
	 * 实操裁判C打分
	 * @return
	 */
	@GetMapping("/scoingc1")
	@ResponseBody
	@RequiresPermissions("jzweb:stuSignUpScoring:scoingc1")
	Result<String>  scoingc(ResultsImgMp4Vo resultsImgMp4Vo){

		List<ExaminationResultsComDO> examinationAnswerSheetDOs = examinationResultsService
				.findByKv("stu_sign_id", resultsImgMp4Vo.getId());
		if(examinationAnswerSheetDOs.size()==0){
			return 	Result.fail("未进行阅卷不能进行评分！");
		}
		if(resultsImgMp4Vo.getScoingc1()!=null){
			examinationAnswerSheetDOs.get(0).setScoingc1(resultsImgMp4Vo.getScoingc1());
		}
		if(resultsImgMp4Vo.getScoingc1s()!=null){
			examinationAnswerSheetDOs.get(0).setScoingc1s(resultsImgMp4Vo.getScoingc1s());
		}
		boolean b = examinationResultsService.updateById(examinationAnswerSheetDOs.get(0));
		ExaminationResultsComResourcesDO resultsComResourcesDO=imgMp4ComService.findOneByKv("results_id",resultsImgMp4Vo.getIds());

		if(resultsComResourcesDO==null){
			ExaminationResultsComResourcesDO comResourcesDO=new ExaminationResultsComResourcesDO();
			comResourcesDO.setResultsId(resultsImgMp4Vo.getIds());
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingc1img())){
				comResourcesDO.setScoingc1img(resultsImgMp4Vo.getScoingc1img());


			}
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingc1smp4())) {
				comResourcesDO.setScoingc1smp4(resultsImgMp4Vo.getScoingc1smp4());
			}
			imgMp4ComService.insert(comResourcesDO);
			}else {
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingc1img())){
				resultsComResourcesDO.setScoingc1img(resultsImgMp4Vo.getScoingc1img());
			}
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingc1smp4())){
				resultsComResourcesDO.setScoingc1smp4(resultsImgMp4Vo.getScoingc1smp4());
			}
			imgMp4ComService.updateById(resultsComResourcesDO);
		}

		return b==true?Result.ok():Result.fail();
	}

	/**
	 * 实操裁判C打分
	 * @return
	 */
	@GetMapping("/scoingc2")
	@ResponseBody
	@RequiresPermissions("jzweb:stuSignUpScoring:scoingc2")
	Result<String>  scoingc2(ResultsImgMp4Vo resultsImgMp4Vo){

		List<ExaminationResultsComDO> examinationAnswerSheetDOs = examinationResultsService
				.findByKv("stu_sign_id", resultsImgMp4Vo.getId());
		if(examinationAnswerSheetDOs.size()==0){
			return 	Result.fail("未进行阅卷不能进行评分！");
		}
		if(resultsImgMp4Vo.getScoingc2()!=null){
			examinationAnswerSheetDOs.get(0).setScoingc2(resultsImgMp4Vo.getScoingc2());
		}
		if(resultsImgMp4Vo.getScoingc2s()!=null){
			examinationAnswerSheetDOs.get(0).setScoingc2s(resultsImgMp4Vo.getScoingc2s());
		}
		boolean b = examinationResultsService.updateById(examinationAnswerSheetDOs.get(0));
		ExaminationResultsComResourcesDO resultsComResourcesDO=imgMp4ComService.findOneByKv("results_id",resultsImgMp4Vo.getIds());

		if(resultsComResourcesDO==null){
			ExaminationResultsComResourcesDO comResourcesDO=new ExaminationResultsComResourcesDO();
			comResourcesDO.setResultsId(resultsImgMp4Vo.getIds());
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingc1img())){
				comResourcesDO.setScoingc2img(resultsImgMp4Vo.getScoingc1img());


			}
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingc1smp4())) {
				comResourcesDO.setScoingc2smp4(resultsImgMp4Vo.getScoingc1smp4());
			}
			imgMp4ComService.insert(comResourcesDO);
			}else {
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingc1img())){
				resultsComResourcesDO.setScoingc2img(resultsImgMp4Vo.getScoingc1img());
			}
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingc1smp4())){
				resultsComResourcesDO.setScoingc2smp4(resultsImgMp4Vo.getScoingc1smp4());
			}
			imgMp4ComService.updateById(resultsComResourcesDO);
		}


		return b==true?Result.ok():Result.fail();
	}



	/**
	 * 实操裁判C打分
	 * @return
	 */
	@GetMapping("/scoingc3")
	@ResponseBody
	@RequiresPermissions("jzweb:stuSignUpScoring:scoingc3")
	Result<String>  scoingc3(ResultsImgMp4Vo resultsImgMp4Vo){

		List<ExaminationResultsComDO> examinationAnswerSheetDOs = examinationResultsService
				.findByKv("stu_sign_id", resultsImgMp4Vo.getId());
		if(examinationAnswerSheetDOs.size()==0){
			return 	Result.fail("未进行阅卷不能进行评分！");
		}
		if(resultsImgMp4Vo.getScoingc3()!=null){
			examinationAnswerSheetDOs.get(0).setScoingc3(resultsImgMp4Vo.getScoingc3());
		}
		if(resultsImgMp4Vo.getScoingc3s()!=null){
			examinationAnswerSheetDOs.get(0).setScoingc3s(resultsImgMp4Vo.getScoingc3s());
		}
		ExaminationResultsComResourcesDO resultsComResourcesDO=imgMp4ComService.findOneByKv("results_id",resultsImgMp4Vo.getIds());
		boolean b = examinationResultsService.updateById(examinationAnswerSheetDOs.get(0));
		if(resultsComResourcesDO==null){
			ExaminationResultsComResourcesDO comResourcesDO=new ExaminationResultsComResourcesDO();
			comResourcesDO.setResultsId(resultsImgMp4Vo.getIds());
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingc1img())){
				comResourcesDO.setScoingc3img(resultsImgMp4Vo.getScoingc1img());


			}
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingc1smp4())) {
				comResourcesDO.setScoingc3smp4(resultsImgMp4Vo.getScoingc1smp4());
			}
			imgMp4ComService.insert(comResourcesDO);
			}else {
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingc1img())){
				resultsComResourcesDO.setScoingc3img(resultsImgMp4Vo.getScoingc1img());
			}
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingc1smp4())){
				resultsComResourcesDO.setScoingc3smp4(resultsImgMp4Vo.getScoingc1smp4());
			}
			imgMp4ComService.updateById(resultsComResourcesDO);
		}

		return b==true?Result.ok():Result.fail();
	}


	/**
	 * 实操裁判C4打分
	 * @return
	 */
	@GetMapping("/scoingc4")
	@ResponseBody
	@RequiresPermissions("jzweb:stuSignUpScoring:scoingc4")
	Result<String>  scoingc4(ResultsImgMp4Vo resultsImgMp4Vo){

		List<ExaminationResultsComDO> examinationAnswerSheetDOs = examinationResultsService
				.findByKv("stu_sign_id", resultsImgMp4Vo.getId());
		if(examinationAnswerSheetDOs.size()==0){
			return 	Result.fail("未进行阅卷不能进行评分！");
		}
		if(resultsImgMp4Vo.getScoingc4()!=null){
			examinationAnswerSheetDOs.get(0).setScoingc4(resultsImgMp4Vo.getScoingc4());
		}
		if(resultsImgMp4Vo.getScoingc4s()!=null){
			examinationAnswerSheetDOs.get(0).setScoingc4s(resultsImgMp4Vo.getScoingc4s());
		}

		boolean b = examinationResultsService.updateById(examinationAnswerSheetDOs.get(0));
		ExaminationResultsComResourcesDO resultsComResourcesDO=imgMp4ComService.findOneByKv("results_id",resultsImgMp4Vo.getIds());

		if(resultsComResourcesDO==null){
			ExaminationResultsComResourcesDO comResourcesDO=new ExaminationResultsComResourcesDO();
			comResourcesDO.setResultsId(resultsImgMp4Vo.getIds());
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingc1img())){
				comResourcesDO.setScoingc4img(resultsImgMp4Vo.getScoingc1img());


			}
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingc1smp4())) {
				comResourcesDO.setScoingc4smp4(resultsImgMp4Vo.getScoingc1smp4());
			}
			imgMp4ComService.insert(comResourcesDO);
			}else {
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingc1img())){
				resultsComResourcesDO.setScoingc4img(resultsImgMp4Vo.getScoingc1img());
			}
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingc1smp4())){
				resultsComResourcesDO.setScoingc4smp4(resultsImgMp4Vo.getScoingc1smp4());
			}
			imgMp4ComService.updateById(resultsComResourcesDO);
		}
		return b==true?Result.ok():Result.fail();
	}
	/**
	 * 实操裁判C5打分
	 * @return
	 */
	@GetMapping("/scoingc5")
	@ResponseBody
	@RequiresPermissions("jzweb:stuSignUpScoring:scoingc5")
	Result<String>  scoingc5(ResultsImgMp4Vo resultsImgMp4Vo){

		List<ExaminationResultsComDO> examinationAnswerSheetDOs = examinationResultsService
				.findByKv("stu_sign_id", resultsImgMp4Vo.getId());
		if(examinationAnswerSheetDOs.size()==0){
			return 	Result.fail("未进行阅卷不能进行评分！");
		}
		if(resultsImgMp4Vo.getScoingc5()!=null){
			examinationAnswerSheetDOs.get(0).setScoingc5(resultsImgMp4Vo.getScoingc5());
		}
		if(resultsImgMp4Vo.getScoingc5s()!=null){
			examinationAnswerSheetDOs.get(0).setScoingc5s(resultsImgMp4Vo.getScoingc5s());
		}

		boolean b = examinationResultsService.updateById(examinationAnswerSheetDOs.get(0));
		ExaminationResultsComResourcesDO resultsComResourcesDO=imgMp4ComService.findOneByKv("results_id",resultsImgMp4Vo.getIds());

		if(resultsComResourcesDO==null){
			ExaminationResultsComResourcesDO comResourcesDO=new ExaminationResultsComResourcesDO();
			comResourcesDO.setResultsId(resultsImgMp4Vo.getIds());
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingc1img())){
				comResourcesDO.setScoingc5img(resultsImgMp4Vo.getScoingc1img());


			}
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingc1smp4())) {
				comResourcesDO.setScoingc5smp4(resultsImgMp4Vo.getScoingc1smp4());
			}
			imgMp4ComService.insert(comResourcesDO);
			}else {
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingc1img())){
				resultsComResourcesDO.setScoingc5img(resultsImgMp4Vo.getScoingc1img());
			}
			if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingc1smp4())){
				resultsComResourcesDO.setScoingc5smp4(resultsImgMp4Vo.getScoingc1smp4());
			}
			imgMp4ComService.updateById(resultsComResourcesDO);
		}
		return b==true?Result.ok():Result.fail();
	}



	/**
	 * 实操裁判C打分
	 * @return
	 */
	@GetMapping("/updateScoingBC")
	@ResponseBody
	Result<String>  updateScoingBC(Long id, OneLevelComVO oneLevelComVO){

		List<ExaminationResultsComDO> examinationAnswerSheetDOs = examinationResultsService
				.findByKv("stu_sign_id", id);
		if(examinationAnswerSheetDOs.size()==0){
			return 	Result.fail("未进行阅卷不能进行评分！");
		}
		if(oneLevelComVO.getScoingc3()>0){
			examinationAnswerSheetDOs.get(0).setScoingc3(oneLevelComVO.getScoingc3());
		}
		if(oneLevelComVO.getScoingc2()>0){
			examinationAnswerSheetDOs.get(0).setScoingc2(oneLevelComVO.getScoingc2());
		}
		if(oneLevelComVO.getScoingc1()>0){
			examinationAnswerSheetDOs.get(0).setScoingc1(oneLevelComVO.getScoingc1());
		}
		if(oneLevelComVO.getScoingc4()>0){
			examinationAnswerSheetDOs.get(0).setScoingc4(oneLevelComVO.getScoingc4());
		}
		if(oneLevelComVO.getScoingc5()>0){
			examinationAnswerSheetDOs.get(0).setScoingc5(oneLevelComVO.getScoingc5());
		}



		if(oneLevelComVO.getScoingb1()>0){
			examinationAnswerSheetDOs.get(0).setScoingb1(oneLevelComVO.getScoingb1());
		}
		if(oneLevelComVO.getScoingb2()>0){
			examinationAnswerSheetDOs.get(0).setScoingb2(oneLevelComVO.getScoingb2());
		}
		if(oneLevelComVO.getScoingb3()>0){
			examinationAnswerSheetDOs.get(0).setScoingb3(oneLevelComVO.getScoingb3());
		}
		if(oneLevelComVO.getScoingb4()>0){
			examinationAnswerSheetDOs.get(0).setScoingb4(oneLevelComVO.getScoingb4());
		}
		if(oneLevelComVO.getScoingb5()>0){
			examinationAnswerSheetDOs.get(0).setScoingb5(oneLevelComVO.getScoingb5());
		}




		if(oneLevelComVO.getScoingc3s()>0){
			examinationAnswerSheetDOs.get(0).setScoingc3s(oneLevelComVO.getScoingc3s());
		}
		if(oneLevelComVO.getScoingc2s()>0){
			examinationAnswerSheetDOs.get(0).setScoingc2s(oneLevelComVO.getScoingc2s());
		}
		if(oneLevelComVO.getScoingc1s()>0){
			examinationAnswerSheetDOs.get(0).setScoingc1s(oneLevelComVO.getScoingc1s());
		}
		if(oneLevelComVO.getScoingc4s()>0){
			examinationAnswerSheetDOs.get(0).setScoingc4s(oneLevelComVO.getScoingc4s());
		}
		if(oneLevelComVO.getScoingc5s()>0){
			examinationAnswerSheetDOs.get(0).setScoingc5s(oneLevelComVO.getScoingc5s());
		}



		if(oneLevelComVO.getScoingb1s()>0){
			examinationAnswerSheetDOs.get(0).setScoingb1s(oneLevelComVO.getScoingb1s());
		}
		if(oneLevelComVO.getScoingb2s()>0){
			examinationAnswerSheetDOs.get(0).setScoingb2s(oneLevelComVO.getScoingb2s());
		}
		if(oneLevelComVO.getScoingb3s()>0){
			examinationAnswerSheetDOs.get(0).setScoingb3s(oneLevelComVO.getScoingb3s());
		}
		if(oneLevelComVO.getScoingb4s()>0){
			examinationAnswerSheetDOs.get(0).setScoingb4s(oneLevelComVO.getScoingb4s());
		}
		if(oneLevelComVO.getScoingb5s()>0){
			examinationAnswerSheetDOs.get(0).setScoingb5s(oneLevelComVO.getScoingb5s());
		}


		boolean b = examinationResultsService.updateById(examinationAnswerSheetDOs.get(0));
		return b==true?Result.ok():Result.fail();
	}



	/**
	 * 导出错误信息
	 *
	 * @param request
	 * @param response
	 * @throws Exception
	 * @author kl
	 */
	@Log("导出错误信息")
	@GetMapping("/importComError")
	@ResponseBody
	@Transactional
	@RequiresPermissions("jzweb:stuSignUpScoring:import")
	public void download(HttpServletRequest request, HttpServletResponse response) throws Exception {
		// 告诉浏览器用什么软件可以打开此文件
		response.setHeader("content-Type", "application/vnd.ms-excel");
		// 下载文件的默认名称
		response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("考生报名导入错误信息", "UTF-8") + ".xls");
		//编码
		response.setCharacterEncoding("UTF-8");
		String jsonArray = EhCacheUtil.get("stuSignComUp" + this.getUserId()).toString();
		JSONArray arrayList = JSONArray.parseArray(jsonArray);
		//转换为目标对象list
		List<ErroeDownVo> groupList = JSONObject.parseArray(arrayList.toJSONString(), ErroeDownVo.class);
		Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), ErroeDownVo.class, groupList);
		workbook.write(response.getOutputStream());
	}



}
